package com.hm.cms.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.hm.cms.su.BeanUtil;
import com.hm.common.su.bean.PageInfo;
import com.hm.common.util.CommonUtil;

import lombok.Data;

/**
 * @author shishun.wang
 * @date 2017年10月22日 下午7:22:48
 * @version 1.0
 * @describe
 */
@Data
public class HcmsPageBaseInfoVo implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * 站点声明
	 */
	private String siteStatement;

	/**
	 * 关注我二维码
	 */
	private String attQrCode;

	/**
	 * 站定底部描述信息
	 */
	private String siteFtInfo;

	/**
	 * 站点分享
	 */
	private String siteShare;

	/**
	 * 开启登录入口
	 */
	private Boolean openLogin;
	
	/**
	 * 文章目录列表
	 */
	public List<HcmsPageArticleNav> articleCatalogs = new ArrayList<HcmsPageArticleNav>();

	/**
	 * 标签集合
	 */
	private List<HcmsPageTermTaxonomyVo> termTaxonomys = new ArrayList<HcmsPageTermTaxonomyVo>();

	/**
	 * 最新发布
	 */
	private List<HcmsPageArticleNav> newestArticles = new ArrayList<HcmsPageArticleNav>();

	/**
	 * 点击量最高排行
	 */
	private List<HcmsPageArticleNav> clickHighestArticles = new ArrayList<HcmsPageArticleNav>();

	/**
	 * 热门推荐
	 */
	private List<HcmsPageArticleNav> hotArticles = new ArrayList<HcmsPageArticleNav>();
	
	public HcmsPageBaseInfoVo articleCatalog(PageInfo<HcmsArticleVo> articleVos) {
		articleVos.getContent().forEach(articleVo -> {
			if(CommonUtil.isEmpty(articleVo)){
				return;
			}
			HcmsPageArticleNav articleNav = new HcmsPageArticleNav();
			BeanUtil.copyProperties(articleVo, articleNav);
			articleNav.setOpenUri(articleVo.getStaticizeUri());
			articleCatalogs.add(articleNav);
		});
		return this;
	}

	public HcmsPageBaseInfoVo newestArticle(PageInfo<HcmsArticleVo> articleVos) {
		articleVos.getContent().forEach(articleVo -> {
			if(CommonUtil.isEmpty(articleVo)){
				return;
			}
			HcmsPageArticleNav articleNav = new HcmsPageArticleNav();
			BeanUtil.copyProperties(articleVo, articleNav);
			articleNav.setOpenUri(articleVo.getStaticizeUri());
			newestArticles.add(articleNav);
		});
		return this;
	}

	public HcmsPageBaseInfoVo clickHighestArticle(PageInfo<HcmsArticleVo> articleVos) {
		articleVos.getContent().forEach(articleVo -> {
			if(CommonUtil.isEmpty(articleVo)){
				return;
			}
			HcmsPageArticleNav articleNav = new HcmsPageArticleNav();
			BeanUtil.copyProperties(articleVo, articleNav);
			articleNav.setOpenUri(articleVo.getStaticizeUri());
			clickHighestArticles.add(articleNav);
		});
		return this;
	}

	public HcmsPageBaseInfoVo hotArticle(PageInfo<HcmsArticleVo> articleVos) {
		articleVos.getContent().forEach(articleVo -> {
			if(CommonUtil.isEmpty(articleVo)){
				return;
			}
			HcmsPageArticleNav articleNav = new HcmsPageArticleNav();
			BeanUtil.copyProperties(articleVo, articleNav);
			articleNav.setOpenUri(articleVo.getStaticizeUri());
			hotArticles.add(articleNav);
		});
		return this;
	}

	public HcmsPageBaseInfoVo termTaxonomy(List<HcmsTermTaxonomyVo> termTaxonomyVos) {
		termTaxonomyVos.forEach(termTax -> {
			if(CommonUtil.isEmpty(termTax)){
				return;
			}
			HcmsPageTermTaxonomyVo taxonomyVo = new HcmsPageTermTaxonomyVo();
			taxonomyVo.setTermTaxName(termTax.getTermTayName());
			taxonomyVo.setTermTaxUri("o_term_taxonomy/tags/"+termTax.getTermTayCode());
			termTaxonomys.add(taxonomyVo);
		});
		return this;
	}
	
	
	/**
	 * @author shishun.wang
	 * @date 2017年10月23日 上午1:17:14
	 * @version 1.0
	 * @describe
	 */
	@Data
	public static class HcmsPageArticleNav implements Serializable {

		private static final long serialVersionUID = 1L;

		/**
		 * 作者名字
		 */
		private String authorName;

		/**
		 * 发布时间
		 */
		private Long releaseTime;

		/**
		 * 标题
		 */
		private String title;

		/**
		 * 缩略图
		 */
		private String breviaryIcon;

		/**
		 * 文章摘录
		 */
		private String articleExcerpt;

		/**
		 * 文章阅读数量
		 */
		private Integer viewQuantity;

		/**
		 * 文章评论数量
		 */
		private Integer commentQuantity;

		/**
		 * 打开链接
		 */
		private String openUri;

		/**
		 * 当前页面排列顺序
		 */
		private Integer articleOrder;

	}

	/**
	 * @author shishun.wang
	 * @date 2017年10月23日 上午12:06:40
	 * @version 1.0
	 * @describe
	 */
	@Data
	public static class HcmsPageTermTaxonomyVo implements Serializable {

		private static final long serialVersionUID = 1L;

		private String termTaxName;
		
		private String termTaxUri;

	}
}
